﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;

namespace engine
{
    public class HookCamera : Camera
    {
        public Vector3 Offset { get; set; }
        public Matrix Orientation { get; set; }
        public SceneNode HookedNode { get; set; }

        /// <summary>
        /// HookCamera constructor
        /// </summary>
        /// <param name="Position"></param>
        /// <param name="Target"></param>
        /// <param name="UpVector"></param>
        /// <param name="FieldOfView"></param>
        /// <param name="NearPlaneDistance"></param>
        /// <param name="FarPlaneDistance"></param>
        /// <param name="AspectRatio"></param>
        /// <param name="Offset"></param>
        /// <param name="Orientation"></param>
        public HookCamera(Vector3 Position, Vector3 Target, Vector3 UpVector,
            float FieldOfView, float NearPlaneDistance, float FarPlaneDistance, float AspectRatio, 
            Vector3 Offset, Matrix Orientation)
            : base(Position, Target, UpVector, FieldOfView, NearPlaneDistance, FarPlaneDistance, AspectRatio)
        {
            this.Offset = Offset;
            this.Orientation = Orientation;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        public void HookOn(SceneNode node)
        {
            HookedNode = node;
        }

        /// <summary>
        /// 
        /// </summary>
        public override void Update()
        {
            Target = Vector3.Transform(Target, HookedNode.World);
            Position = Target - Offset;
        }
    }
}

